import 'package:flutter/cupertino.dart';
import 'package:tender_flutter/http/api_response.dart';
import 'package:tender_flutter/manager/permission_manager.dart';
import 'package:tender_flutter/router/router.dart';

abstract class BaseWidget extends StatefulWidget {
  @override
  BaseWidgetState createState() => getState();

  BaseWidgetState getState();
}

abstract class BaseWidgetState<T extends BaseWidget> extends State<T> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {}

  /// 根据请求结果做处理
  handleResponse({ApiResponse response}) {
    if (response == null) {
      return;
    }
    if (response.status == Status.NOPERMISSION) {
      // 没有权限（没开通VIP或者查询次数已用完）
      PermissionManager.showFreePermissDialog()
          .then((value) => LRouter.navigatorCtx(context).pop());
    }
  }
}
